package com.pocketsweet.ui.uilib;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;

import com.pocketsweet.R;

public class MyRatingBar extends LinearLayout {
	private RatingBar ratingBar;
	public int score=0;

	public MyRatingBar(Context context) {
		super(context);
		// 初始化
		init(context);
	}

	public MyRatingBar(Context context, AttributeSet attrs) {
		super(context, attrs);

		// 初始化
		init(context);
	}

	private void init(Context context) {
		View root = inflate(context, R.layout.view_rating_bar, null);
		ratingBar = (RatingBar) root.findViewById(R.id.rating_bar);
		addView(root);
		OnRatingBarChangeListener orbcl = new OnRatingBarChangeListener() {
			public void onRatingChanged(RatingBar ratingBar, float rating,
					boolean fromUser) {
				score = (int) rating;
			}
		};
		ratingBar.setOnRatingBarChangeListener(orbcl);
	}

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}
}
